using System.Collections;
using System.Collections.Generic;
using System.Text;
using ICSharpCode.TextEditor.Formatting.TSqlFormatter.Interfaces;

namespace ICSharpCode.TextEditor.Formatting.TSqlFormatter
{
    public class TokenList : List<IToken>, ITokenList, IList<IToken>, ICollection<IToken>, IEnumerable<IToken>, IEnumerable
    {
        public bool HasUnfinishedToken { get; set; }

        public string PrettyPrint()
        {
            StringBuilder stringBuilder = new StringBuilder();
            using (Enumerator enumerator = GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    IToken current = enumerator.Current;
                    string text = current.Type.ToString();
                    stringBuilder.Append(text.PadRight(20));
                    stringBuilder.Append(": ");
                    stringBuilder.AppendLine(current.Value);
                }
            }
            return stringBuilder.ToString();
        }

        public new IList<IToken> GetRange(int index, int count)
        {
            return base.GetRange(index, count);
        }

        public IList<IToken> GetRangeByIndex(int fromIndex, int toIndex)
        {
            return GetRange(fromIndex, toIndex - fromIndex + 1);
        }
    }
}
